void foo()

{

  double var = 2.7;

  var++;

}



int

main()

{

  // unmask FPU #IE(Invalid Operation Exception) flag of control word

  unsigned short custom = 0;

  asm("fstcw %0"

      :

      : "m" (custom));

  custom &= 0xfffe;

  asm("fldcw %0"

      :

      : "m" (custom));

  // before foo(), FPU registers stack is empty

  foo();

  // after foo(), st(0) is left unclean

  asm("fld1;"

      "fld1;"

      "fld1;"

      "fld1;"

      "fld1;"

      "fld1;"

      "fld1;"

      "fld1;");

  // fnop will throw a FPU #IE exception if the bug exists

  asm("fnop");
  printf("ok!");
  return 0;

}